#!/bin/bash

read -p "服务名称：" name
time=$( systemctl status $name | grep Active | awk '{print $5,$6,$7,$8}') 
pid=$(systemctl status $name | grep  PID |tail -1| awk '{print $3}')
jincheng=$(systemctl status $name | grep $name.service | head -1 | awk '{print $2}')
duankou=$(netstat -ntulp | grep $name | awk '{print $4}' | awk -F: '{print $4}')


systemctl status $name &> /dev/null

if [ $? -eq 0 ]; then
   echo "启动时间：" $time
   echo "PID：" $pid
   echo "进程名称：" $jincheng
   echo "端口：" $duankou
else
   echo "没有启动！！！"
fi
